#include <vector>
#include <fstream>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim.hpp>
#include "data_source.h"

using namespace boost;

DataSource::DataSource(string file_path)
{
    string line;
    vector<string> line_vector;
    ifstream myfile(file_path.c_str());

    if (myfile.is_open())
    {
        while (getline(myfile,line))
        {
            trim(line);
            line_vector.clear();
            split(line_vector, line, is_any_of("\t"));
            set<string> user_set(++line_vector.begin(), line_vector.end());
            product_user_set_map[line_vector[0]] = user_set;
        }
        myfile.close();
    }
    else
        cout << "Uable to open file." << endl;
}
